﻿using System;

namespace Program25
{
    class Program
    {
        static void Main(string[] args)
        {
            //// GetSum(1,6,20,56...）求任意长度的和
            //Console.WriteLine(GetSum(11, 17，20，32));
            //Console.WriteLine(GetSum(8, 9, 1, 4, 53, 109));

            //Test("叽叽叽", "12级", 99, 99);

            GetScore("hong", 320, 87, 90, 88);
        }

        // params定义可变参数
        public static int GetSum(params int[] n)
        {
            var sum = 0;
            for (var i = 0; i < n.Length; i++)
            {
                sum += n[i];
            }

            return sum;
        }

        public static void Test(params Object[] objs)
        {
            Console.WriteLine(objs[0]);
            Console.WriteLine(objs[1]);
            Console.WriteLine(objs[2]);
            Console.WriteLine(objs[3]);
        }

        //可变参数放在所有形参的末尾
        public static void GetScore(string name, int id, params int[] scores)
        {
            Console.WriteLine("学号：" + id);
            Console.WriteLine("姓名：" + name);
            var sum = 0;
            for (var i = 0; i < scores.Length; i++)
            {
                sum += scores[i];
            }
            Console.WriteLine("总分：" + sum);
            Console.WriteLine("平均分：" + sum / scores.Length);
        }
    }
}
